<?php

namespace app\api\model\v1;

use think\Model;
use traits\model\SoftDelete;

class ActivityForm extends Model
{

    use SoftDelete;


    // 表名
    protected $name = 'activity_form';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'isrequired_text',
        'type_text'
    ];
    

    
    public function getIsrequiredList()
    {
        return ['0' => __('Isrequired 0'), '1' => __('Isrequired 1')];
    }

    public function getTypeList()
    {
        return ['0' => __('Type 0'), '1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3'), '4' => __('Type 4')];
    }


    public function getIsrequiredTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['isrequired']) ? $data['isrequired'] : '');
        $list = $this->getIsrequiredList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
